﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using Model;
namespace DAL
{
  public  class DAL_Tables
    {
        public static DataTable CXZuoZi(Model_Tables t) {
            string sql = "select * from Tables where RTID=@RTID";
            List<SqlParameter> list = new List<SqlParameter>{
            new SqlParameter("@RTID",t.RTID),
            
          };
            return DBHelper.Dataset(sql, list);
        }
      //桌子总数
        public static object ZhuoZiCOUNT()
        {
            string sql = " SELECT COUNT(*) FROM Tables";
            return DBHelper.Chadanzhi(sql, null);
        }
        //当前站用数
        public static object ZhuoZi_ZY_S()
        {
            string sql = @" 
 SELECT COUNT(*) FROM Tables
 where TableState=1";
            return DBHelper.Chadanzhi(sql, null);
        }
        //当前预订数
        public static object ZhuoZi_YD_S()
        {
            string sql = @" 
 SELECT COUNT(*) FROM Tables
 where TableState=2";

            return DBHelper.Chadanzhi(sql, null);
        }
        //当前停用数
        public static object ZhuoZi_TY_S()
        {
            string sql = @" 
 SELECT COUNT(*) FROM Tables
 where TableState=3";
            return DBHelper.Chadanzhi(sql, null);
        }
        //当前可用数
        public static object ZhuoZi_KY_S()
        {
            string sql = @" 
 SELECT COUNT(*) FROM Tables
 where TableState=0";
            return DBHelper.Chadanzhi(sql, null);
        }
        //修改餐桌状态
        public static int UP_ZhuoZi_ZT(string TableID)
        {
            string sql = @" 
 update Tables set TableState=1 where TableID=@TableID";
            List<SqlParameter> list = new List<SqlParameter>
            {
                new SqlParameter("@TableID",TableID)
            };
            return DBHelper.Update(sql,list.ToArray());
        }
    }
}
